﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using DTO;

namespace DAO
{
    public class PhieuNhapSachDAO : AbstractDAO
    {
        public List<PhieuNhapSachDTO> GetAll()
        {
            OleDbConnection connection = Open();
            string sql = "SELECT * FROM PhieuNhap";
            OleDbCommand command = new OleDbCommand(sql, connection);
            OleDbDataReader reader = command.ExecuteReader();
            List<PhieuNhapSachDTO> dsPhieuNhapSach = new List<PhieuNhapSachDTO>();
            PhieuNhapSachDTO s;
            while (reader.Read())
            {
                s = new PhieuNhapSachDTO();
                s.MaPhieuNhap = reader.GetInt32(0);
                s.NgayNhap = reader.GetDateTime(1);
                s.TinhTrang = reader.GetBoolean(2);
                dsPhieuNhapSach.Add(s);
            }
            Close(connection);
            return dsPhieuNhapSach;
        }
    }
}
